#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：pythonProject2 
@File    ：client.py
@Author  ：beibei
@Date    ：2023/12/22 3:31 PM 
'''
import socket

def push_message(message):
    client_socket.send(f'push:{message}'.encode('utf-8'))

def pull_messages():
    client_socket.send('pull'.encode('utf-8'))
    response = client_socket.recv(4096)
    print(f"Received: {response.decode('utf-8')}")

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(('localhost', 5000))

# 用例
push_message('abc')
push_message('qwe')
pull_messages()  # 应该看到'abc','qwe'
pull_messages()  # 应该看到空列表

client_socket.close()
